<template>
    <!-- 维护作业-照会代码维护页面 -->
    <div class="fillcontain">
        <el-form :model="searchParams" label-width="100px" class="search_container">
            <el-row>
                <el-col :span="6">
                    <el-form-item label="照会代码" prop="pncode">
                        <el-input clearable v-model="searchParams.pncode" @blur="searchParams.pncode = searchParams.pncode.toUpperCase()" placeholder=""></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="照会类别" prop="pntype">
                        <el-input clearable v-model="searchParams.pntype" @blur="searchParams.pntype = searchParams.pntype.toUpperCase()" placeholder=""></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="6" class="text_center">
                    <el-button type="primary" icon="el-icon-search" @click="subGetList"></el-button>
                    <el-button type="primary" plain icon="el-icon-refresh" @click="resetSearch"></el-button>
                </el-col>
            </el-row>
        </el-form>
        <div class="contain">
            <el-row class="bgfff pb15">
                <el-col :span="24" class="pt5">
                    <el-button type="danger" plain @click="addEufakpay()">新增</el-button>
                    <el-button type="danger" plain @click="exportExcel()">导出</el-button>
                </el-col>
            </el-row>
            <!-- 查询结果 -->
            <div class="table_container">
                <el-table v-loading="loading" :data=" replyCodetableData" highlight-current-row header-cell-class-name="table-header-class"
                    style="width:100%">
                    <el-table-column min-width="80" property="pncode" label="照会代码" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="80" property="pntype" label="照会类别" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="140" property="source" label="照会来源" align='center' :formatter="sourceFormatter" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="100" property="forceind" label="Force able" align='center' :formatter="forceindFormatter" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="160" property="zresnpd" label="照会性质" align='center' :formatter="zresnpdFormatter" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="100" property="resind" label="User Resol" align='center' :formatter="resindFormatter" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column width="80" property="nofday" label="催办天数" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="80" property="prtopt" label="直接列印" :formatter="prtoptFormatter" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="80" property="authnow" label="自动授权" align='center' :formatter="authnowFormatter" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="600" property="pedesc" label="照会说明" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="80" property="memodesc" label="备注" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="80" property="remindday" label="提醒日" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="120" property="srpisno" label="需求号码" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="80" property="updateInd" label="更新方式" align='center' :formatter="updateIndFormatter" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column min-width="150" fixed="right" label="操作" align='center'>
                        <template slot-scope="scope">
                            <!-- <el-button type="text" size="small" @click="replyCodeUpdateGo(scope.row)">修改</el-button> -->
                            <span class="operationIcon" @click="replyCodeUpdateGo(scope.row)">
                                <el-tooltip class="item" effect="light" content="修改" placement="top">
                                    <i class="el-icon-edit"></i>
                                </el-tooltip>
                            </span>

                            <!-- <el-button type="text" size="small" @click="deleteData(scope.row)">删除</el-button> -->
                            <span class="operationIcon ml5" @click="deleteData(scope.row)">
                                <el-tooltip class="item" effect="light" content="删除" placement="top">
                                    <i class="el-icon-delete"></i>
                                </el-tooltip>
                            </span>
                        </template>
                    </el-table-column>
                </el-table>
                <el-row>
                    <el-col :span="24">
                        <div class="pagination">
                            <el-pagination background v-if='paginations.total > 0' :page-sizes="paginations.pageSizes" :page-size="paginations.pageSize"
                                :layout="paginations.layout" :total="paginations.total" :current-page='paginations.pageIndex'
                                @current-change='handleCurrentChange' @size-change='handleSizeChange'>
                            </el-pagination>
                        </div>
                    </el-col>
                </el-row>
            </div>
        </div>
        <!-- 弹框 修改-->
        <el-dialog title="照会代码维护" v-if="replyCodeDialog" :visible.sync="replyCodeDialog" width="60%" center>
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="照会代码" prop="pncode">
                            <el-input clearable placeholder="" maxlength="5" v-model="form.pncode" :disabled="editType=='modify'"></el-input>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">照会代码</label>
                        </el-col>
                         <el-col :span="16">
                             <el-input placeholder="" v-model="form.pncode" :readonly="editType=='modify'"></el-input>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="照会类别" prop="pntype">
                            <el-input clearable placeholder="" maxlength="5" v-model="form.pntype" @blur="form.pntype = form.pntype.toUpperCase()"></el-input>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">照会类别</label>
                        </el-col>
                         <el-col :span="16">
                             <el-input placeholder="" v-model="form.pntype"></el-input>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="照会来源" prop="source">
                            <el-select v-model="form.source" placeholder="">
                                <el-option v-for="item in sources" :key="item.value" :label="item.option" :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">照会来源</label>
                        </el-col>
                         <el-col :span="16">
                             <el-select v-model="form.source" placeholder="" >
                                <el-option
                                    v-for="item in sources"
                                    :key="item.value"
                                    :label="item.option"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="Force able" prop="forceind">
                            <el-select v-model="form.forceind" placeholder="">
                                <el-option v-for="item in forceinds" :key="item.value" :label="item.label" :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">Force able</label>
                        </el-col>
                         <el-col :span="16">
                            <el-select v-model="form.forceind" placeholder="" >
                                <el-option
                                    v-for="item in forceinds"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="照会性质" prop="zresnpd">
                            <el-select v-model="form.zresnpd" placeholder="">
                                <el-option v-for="item in zresnpds" :key="item.value" :label="item.option" :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">照会性质</label>
                        </el-col>
                         <el-col :span="16">
                            <el-select v-model="form.zresnpd" placeholder="" >
                                <el-option
                                    v-for="item in zresnpds"
                                    :key="item.value"
                                    :label="item.option"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="User Resol" prop="resind">
                            <el-select v-model="form.resind" placeholder="">
                                <el-option v-for="item in resinds" :key="item.value" :label="item.label" :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">User Resol</label>
                        </el-col>
                         <el-col :span="16">
                            <el-select v-model="form.resind" placeholder="" >
                                <el-option
                                    v-for="item in resinds"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="催办天数" prop="nofday">
                            <el-input clearable placeholder="" v-model="form.nofday" maxlength="3"></el-input>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">催办天数</label>
                        </el-col>
                         <el-col :span="16">
                             <el-input placeholder="" v-model="form.nofday"></el-input>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="直接列印" prop="prtopt">
                            <el-select v-model="form.prtopt" placeholder="">
                                <el-option v-for="item in prtopts" :key="item.value" :label="item.label" :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName" >直接列印</label>
                        </el-col>
                         <el-col :span="16">
                            <el-select v-model="form.prtopt" placeholder="" >
                                <el-option
                                    v-for="item in prtopts"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="自动授权" prop="authnow">
                            <el-select v-model="form.authnow" placeholder="">
                                <el-option v-for="item in authnows" :key="item.value" :label="item.label" :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">自动授权</label>
                        </el-col>
                         <el-col :span="16">
                            <el-select v-model="form.authnow" placeholder="" >
                                <el-option
                                    v-for="item in authnows"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="提醒日" prop="remindday">
                            <el-input clearable placeholder="" v-model="form.remindday" maxlength="3"></el-input>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">提醒日</label>
                        </el-col>
                         <el-col :span="16">
                             <el-input placeholder="" v-model="form.remindday"></el-input>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="需求号码" prop="srpisno">
                            <el-input clearable placeholder="" v-model="form.srpisno" @blur="checkSrp(form.srpisno)" maxlength="10" @change="form.srpisno = form.srpisno.toUpperCase()"></el-input>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">需求号码</label>
                        </el-col>
                         <el-col :span="16">
                             <el-input placeholder="" v-model="form.srpisno"></el-input>
                         </el-col> -->
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="更新方式" prop="updateInd">
                            <el-select v-model="form.updateInd" placeholder="">
                                <el-option v-for="item in update_inds" :key="item.value" :label="item.label" :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- <el-col :span="6" class="common-lab">
                             <label class="labelName">更新方式</label>
                        </el-col>
                         <el-col :span="16">
                            <el-select v-model="form.updateInd" placeholder="" >
                                <el-option
                                    v-for="item in update_inds"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                         </el-col> -->
                    </el-col>
                    <el-col :span="24" class="common-box">
                        <el-form-item label="备注" prop="memodesc">
                            <el-input clearable type="textarea" placeholder="" v-model="form.memodesc" maxlength="50"></el-input>
                        </el-form-item>
                        <!-- <el-col :span="3" class="common-lab">
                             <label class="labelName">备注</label>
                        </el-col>
                         <el-col :span="20">
                             <el-input clearable type="textarea"  placeholder="" v-model="form.memodesc"></el-input>
                         </el-col> -->
                    </el-col>
                    <el-col :span="24" class="common-box">
                        <el-form-item label="照会说明" prop="pedesc">
                            <el-input clearable type="textarea" placeholder="" v-model="form.pedesc" maxlength="256"></el-input>
                        </el-form-item>
                        <!-- <el-col :span="3" class="common-lab">
                             <label class="labelName">照会说明</label>
                        </el-col>
                         <el-col :span="20">
                            <el-input clearable type="textarea"  placeholder="" v-model="form.pedesc"></el-input>
                         </el-col> -->
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button v-if="saveButton" @click="onSubmit('form')" class="Defaultbutton">保 存</el-button>
                <el-button @click="replyCodeDialog = false">返 回</el-button>
            </span>
        </el-dialog>

    </div>
</template>

<script>
    import { mapState, mapGetters } from 'vuex'
    import constant from '@/utils/constant';
    import appName from "@/api/appName"
    import { getToken, setToken } from '@/utils/auth'
    import axios from 'axios';
    import { checkPncode, getComCheckList, queryForNoteRule, checkPntype, checkSrpisno, editData, deleteData, qureryListToExcel } from "@/api/setting/replyCodeMaintenance.js";
    export default {
        data() {
            var checkPncodeInfo = (rule, value, callback) => {
                if (this.editType == 'add') {
                    let para = {
                        "pncode": value
                    }
                    checkPncode(para).then(res => {
                        if (res.resultCode == constant.SUCCESS) {
                            if (res.data) {
                                console.log(res)
                                callback(new Error('输入的照会代码重复！'));
                            } else {
                                let CHNReg = /^[0-9a-zA-Z]*$/;//汉字的正则表达式
                                if (!value.match(CHNReg)) {
                                    callback(new Error('照会代码必须为数字或者字母'));
                                } else {
                                    callback();
                                }
                            }
                        } else {
                            callback(new Error('输入的照会代码重复！'));
                        }
                    }).catch(err => {
                        callback(new Error('输入的照会代码重复!'));
                        // this.$store.dispatch('loading/CHANGE_LOADING',false);
                    })
                } else {
                    callback();
                }


            };
            // var validatePncode = (rule, value, callback) => {
            //     let CHNReg = /[a-zA-Z0-9]/;//汉字的正则表达式
            //     if (value.match(CHNReg)) {
            //         callback(new Error('照会代码必须为数字或者字母'));
            //     } else {
            //         callback();
            //     }
            // };
            var validatePntype = (rule, value, callback) => {
                let para = {
                    "pntype": value
                }

                //this.$store.dispatch('loading/CHANGE_LOADING',true)
                checkPntype(para).then(res => {
                    //this.$store.dispatch('loading/CHANGE_LOADING',false)
                    if (res.resultCode == constant.SUCCESS) {
                        if (res.data) {
                            console.log(res)
                            callback();
                        } else {
                            callback(new Error('照会类别不存在'));
                        }
                    } else {
                        callback(new Error('照会类别不存在'));
                    }
                }).catch(err => {
                    callback(new Error('照会类别不存在'));
                    // this.$store.dispatch('loading/CHANGE_LOADING',false);
                })

            };
            var validateSrpisno = (rule, value, callback) => {
                let para = {
                    "srpisno": value
                }

                //this.$store.dispatch('loading/CHANGE_LOADING',true)
                if (value) {
                    checkSrpisno(para).then(res => {
                        //this.$store.dispatch('loading/CHANGE_LOADING',false)
                        if (res.resultCode == constant.SUCCESS) {
                            if (res.data == 0) {
                                callback(new Error('需求号码必须存在且尚未结案'));
                            } else {
                                console.log(res)
                                callback();
                            }
                        } else {
                            callback(new Error('需求号码必须存在且尚未结案'));
                        }
                    }).catch(err => {
                        callback(new Error('需求号码必须存在且尚未结案'));
                        // this.$store.dispatch('loading/CHANGE_LOADING',false);
                    })
                } else {
                    callback();
                }
            };
            var validateNofday = (rule, value, callback) => {
                if (isNaN(value) || value < 1 || value > 999 || value % 1 != 0) {
                    callback(new Error('催办天数：请输入不超过三位数的正整数。'));
                } else {
                    callback();
                }
            };
            var validateNofday = (rule, value, callback) => {
                if (isNaN(value) || value < 1 || value > 999 || value % 1 != 0) {
                    callback(new Error('提醒日:请输入不超过三位数的正整数。'));
                } else {
                    callback();
                }
            };
            return {
                //常量下拉框
                sources: [],
                forceinds: [
                    {
                        value: 'Y',
                        label: '是'
                    },
                    {
                        value: 'N',
                        label: '否'
                    }
                ],
                zresnpds: [],
                resinds: [{
                    value: 'Y',
                    label: '是'
                },
                {
                    value: 'N',
                    label: '否'
                }],
                prtopts: [
                    {
                        value: 'Y',
                        label: '是'
                    },
                    {
                        value: 'N',
                        label: '否'
                    }
                ],
                authnows: [
                    {
                        value: 'Y',
                        label: '是'
                    },
                    {
                        value: 'N',
                        label: '否'
                    }
                ],
                update_inds: [
                    {
                        value: 'I',
                        label: 'I--新增'
                    },
                    {
                        value: 'U',
                        label: 'U--更新'
                    },
                    {
                        value: 'D',
                        label: 'D--删除'
                    }
                ],
                replyCodeDialog: false,//默认隐藏 照会代码维护修改弹框
                // 查询条件
                rules: {
                    pncode: [
                        { required: true, message: '请输入照会代码。' },
                        // { validator: validatePncode, trigger: 'blur' },
                        { validator: checkPncodeInfo, trigger: 'blur' }
                    ],
                    pntype: [
                        { required: true, message: '请输入照会类别。' },
                        { validator: validatePntype, trigger: 'blur' }
                    ],
                    source: [
                        { required: true, message: '请输入照会来源。' },
                    ],
                    forceind: [
                        { required: true, message: '请输入Force able。' },
                    ],
                    zresnpd: [
                        { required: true, message: '请输入照会性质。' },
                    ],
                    resind: [
                        { required: true, message: '请输入User Resol。' },
                    ],
                    nofday: [
                        { required: true, message: '请输入催办天数。' },
                        { validator: validateNofday, trigger: 'blur' }
                    ],
                    prtopt: [
                        { required: true, message: '请输入直接列印。' },
                    ],
                    authnow: [
                        { required: true, message: '请输入自动授权。' },
                    ],
                    remindday: [
                        { required: true, message: '请输入提醒日。' },
                        { validator: validateNofday, trigger: 'blur' }
                    ],
                    // srpisno: [
                    //     { validator: validateSrpisno, trigger: 'blur' }
                    // ],
                    memodesc: [
                        { max: 50, trigger: 'blur' }
                    ],
                    pedesc: [
                        { required: true, message: '请输入照会说明。' },
                        { max: 256, trigger: 'change' }
                    ]
                },
                searchParams: {
                    pncode: '',
                    pntype: '',
                },
                replyCodetableData: [//主档数据
                ],
                loading: false,
                editType: '', //编辑类型，add-新增 modify-修改
                form: { //弹框表单
                    pncode: '',
                    pntype: '',
                    source: '',
                    forceind: '',
                    zresnpd: '',
                    resind: '',
                    nofday: '',
                    prtopt: '',
                    authnow: '',
                    remindday: '',
                    srpisno: '',
                    updateInd: '',
                    memodesc: '',
                    pedesc: ''
                },
                option: '',
                options: [
                    { value: '1', label: '测试1' },
                    { value: '2', label: '测试2' }
                ],
                isCheck: true,
                saveButton: true,
                //需要给分页组件传的信息
                paginations: {
                    total: 0,        // 总数
                    pageIndex: 1,  // 当前位于哪页
                    pageSize: 10,   // 1页显示多少条
                    pageSizes: [5, 10, 15, 20],  //每页显示多少条
                    layout: "total, sizes, prev, pager, next, jumper"   // 翻页属性
                },
                pickerOptions1: {
                    disabledDate(time) {
                        return time.getTime() > Date.now();
                    }
                }
            }
        },
        created() {
            //          this.getList();
        },
        mounted() {
            // this.getList();
            this.querySourceForNoteRule();
            this.queryZresnpdForNoteRule();
        },
        methods: {
            //校验需求号：
            checkSrp(value) {
                this.saveButton = false;
                if (value) {
                    let para = {
                        "srpisno": value
                    }
                    checkSrpisno(para).then(res => {
                        if (res.resultCode == constant.SUCCESS) {
                            if (res.data == 0) {
                                this.isCheck = false;
                                this.$message({
                                    message: '需求号码必须存在且尚未结案',
                                    type: "error"
                                });
                            } else {
                                this.isCheck = true;
                            }
                        } else {
                            this.isCheck = false;
                            this.$message({
                                message: '需求号码必须存在且尚未结案',
                                type: "error"
                            });
                        }
                        this.saveButton = true;
                    }).catch(err => {
                        this.isCheck = false;
                        this.$message({
                            message: '需求号码必须存在且尚未结案',
                            type: "error"
                        });
                        this.saveButton = true;
                    })
                } else {
                    this.isCheck = true;
                    this.saveButton = true;
                }
            },
            //提交
            onSubmit(formName) {
                let _this = this;
                this.$refs[formName].validate((valid) => {
                    console.log(valid);
                    if (!_this.isCheck) {
                        _this.$message({
                            message: '需求号码必须存在且尚未结案',
                            type: "error"
                        });
                        return;
                    }
                    if (valid) {
                        console.log('submit!!');
                        editData(_this.editType, _this.form).then(res => {
                            //this.$store.dispatch('loading/CHANGE_LOADING',false)
                            if (res.resultCode == constant.SUCCESS) {
                                _this.$message({
                                    type: 'success',
                                    message: res.resultMsg
                                });
                                _this.replyCodeDialog = false;
                                _this.paginations.pageIndex = 1;
                                _this.searchParams.pncode = _this.form.pncode;
                                _this.getList();
                            } else {
                                _this.$message({
                                    type: 'error',
                                    message: res.resultMsg
                                });
                            }
                        }).catch(err => {
                            // this.$message({
                            //     type: 'error',
                            //     message: res.resultMsg
                            // });
                            // this.$store.dispatch('loading/CHANGE_LOADING',false);
                        })


                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            //修改
            replyCodeUpdateGo(row) {
                this.replyCodeDialog = true;
                this.isCheck = true;
                this.saveButton = true;
                this.editType = 'modify';
                this.form = row;
            },
            //新增
            addEufakpay() {
                this.replyCodeDialog = true;
                this.editType = 'add';
                this.isCheck = true;
                this.saveButton = true;
                this.form = {
                    pncode: '',
                    pntype: '',
                    source: 'F',
                    forceind: 'Y',
                    zresnpd: '01',
                    resind: 'Y',
                    nofday: '15',
                    prtopt: 'Y',
                    authnow: 'N',
                    remindday: '15',
                    srpisno: '',
                    updateInd: '',
                    memodesc: '',
                    pedesc: ''
                };
            },
            deleteData(row) {
                this.$confirm('确定是否删除？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    let param = {
                        pncode: row.pncode
                    }
                    deleteData(param).then(res => {
                        //this.$store.dispatch('loading/CHANGE_LOADING',false)
                        if (res.resultCode == constant.SUCCESS) {
                            this.$confirm("删除成功!", '提示', {
                                confirmButtonText: '确定',
                                type: 'warning'
                            }).then(() => {
                                this.paginations.pageIndex = 1;
                                this.getList();
                            })
                        }
                    }).catch(err => {
                        // this.$store.dispatch('loading/CHANGE_LOADING',false);
                    })

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            //导出excel
            exportExcel() {
                let url = appName.NB + `/maintain/noteRule/qureryListToExcel`;
                this.$store.dispatch('loading/CHANGE_LOADING', true);
                axios.get(url, {
                    responseType: 'arraybuffer', // 或者responseType: 'blob'
                    xsrfHeaderName: 'Authorization',
                    headers: {
                        'Authorization': getToken(constant.TOKEN) || ''
                    }
                }).then(res => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false);
                    const blob = new Blob([res.data], {
                        type: 'application/vnd.ms-excel;charset=utf-8'
                    })
                    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                        window.navigator.msSaveOrOpenBlob(blob, 'noteRule.xls');
                    }
                    const objectUrl = URL.createObjectURL(blob);
                    // window.location.href = objectUrl

                    const eleLink = document.createElement('a')
                    eleLink.download = 'noteRule.xls'
                    eleLink.style.display = 'none'
                    eleLink.href = objectUrl
                    // 触发点击
                    document.body.appendChild(eleLink)
                    eleLink.click()
                    // 然后移除
                    document.body.removeChild(eleLink)
                }).catch(err => {
                    console.log(err)
                })

            },
            //
            changeToUpperCase(type) {
                if (type == 'pncode') {
                    this.searchParams.pncode = this.searchParams.pncode.toUpperCase();
                } else if (type == 'pntype') {
                    this.searchParams.pntype = this.searchParams.pntype.toUpperCase();
                }
            },

            // 查询列表
            getList() {
                this.paginations.total = 0;
                this.replyCodetableData = [];
                let para = {
                    "pncode": this.searchParams.pncode,
                    "pntype": this.searchParams.pntype,
                    "pageSize": this.paginations.pageSize,
                    "pageNumber": this.paginations.pageIndex,
                }
                // if (!para.pncode && !para.pntype) {
                //     this.$message({
                //         message: '请至少输入一个查询条件来查询！',
                //         type: 'error'
                //     });
                //     return false
                // }
                this.$store.dispatch('loading/CHANGE_LOADING', true)
                getComCheckList(para).then(res => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false)
                    if (res.resultCode == constant.SUCCESS && res.data) {
                        if (res.data.data.rows.length) {
                            this.replyCodetableData = res.data.data.rows;
                            this.paginations.total = res.data.data.total;
                        } else {
                            this.$message({
                                message: '无符合条件任务！',
                                type: 'error'
                            });
                        }

                    }
                }).catch(err => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false);
                })
            },
            // 每页多少条切换
            handleSizeChange(pageSize) {
                this.paginations.pageSize = pageSize;
                this.getList();
            },
            // 上下分页
            handleCurrentChange(page) {
                this.paginations.pageIndex = page;
                this.getList();
            },
            // 根据条件查询列表
            subGetList() {
                this.paginations.pageIndex = 1;
                this.getList();
            },
            // 清除查询条件
            resetSearch() {
                this.searchParams.pncode = '';
                this.searchParams.pntype = '';
            },
            //照会来源下拉框
            querySourceForNoteRule() {
                queryForNoteRule("18").then(res => {
                    //this.$store.dispatch('loading/CHANGE_LOADING',false)
                    if (res.resultCode == constant.SUCCESS && res.data && res.data.length) {
                        this.sources = res.data;
                    }
                }).catch(err => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false);
                })
            },
            //照会性质下拉框
            queryZresnpdForNoteRule() {
                queryForNoteRule("12").then(res => {
                    //this.$store.dispatch('loading/CHANGE_LOADING',false)
                    if (res.resultCode == constant.SUCCESS && res.data && res.data.length) {
                        this.zresnpds = res.data;
                    }
                }).catch(err => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false);
                })
            },
            //照会来源值转换
            sourceFormatter(row) {
                let result = "";
                this.sources.forEach(e => {
                    if (e.value == row.source) {
                        result = e.option;
                        return false;
                    }
                })
                return result;
            },
            forceindFormatter(row) {
                let result = "";
                this.forceinds.forEach(e => {
                    if (e.value == row.forceind) {
                        result = e.label;
                        return false;
                    }
                })
                return result;
            },
            zresnpdFormatter(row) {
                let result = "";
                this.zresnpds.forEach(e => {
                    if (e.value == row.zresnpd) {
                        result = e.option;
                        return false;
                    }
                })
                return result;
            },
            resindFormatter(row) {
                let result = "";
                this.resinds.forEach(e => {
                    if (e.value == row.resind) {
                        result = e.label;
                        return false;
                    }
                })
                return result;
            },
            prtoptFormatter(row) {
                let result = "";
                this.prtopts.forEach(e => {
                    if (e.value == row.prtopt) {
                        result = e.label;
                        return false;
                    }
                })
                return result;
            },
            authnowFormatter(row) {
                let result = "";
                this.authnows.forEach(e => {
                    if (e.value == row.authnow) {
                        result = e.label;
                        return false;
                    }
                })
                return result;
            },
            updateIndFormatter(row) {
                let result = "";
                this.update_inds.forEach(e => {
                    if (e.value == row.updateInd) {
                        result = e.label;
                        return false;
                    }
                })
                return result;
            }
        },
        computed: {
            ...mapGetters(['tags']),
            reload() {
                return this.$store.state.loading.reload;
            }
        },
        activated() {
            if (this.reload) {
                this.$store.dispatch('loading/CHNAGE_RELOAD', false)
                Object.assign(this.$data, this.$options.data());
            }
        }
    }

</script>

<style lang="less" scoped>
    .fillcontain {
        padding-bottom: 0;
    }

    .contain {
        background: #fff;
        padding: 10px;
        margin-bottom: 20px;
    }

    .pagination {
        padding: 10px 20px;
        text-align: right;
    }

    .operationIcon {
        // padding: 12px;
        border: 1px solid #e5e5e5;
        border-radius: 50%;
        width: 22px;
        height: 22px;
        display: inline-block;
        cursor: pointer;
        box-shadow: 0 0 3px #f9f9f9;
    }

    .search_container {
        padding: 20px 20px 0 20px; //    border-top: 1px solid #e1e1e1;
    }

    .common-box {
        padding-bottom: 15px;
    }

    .common-lab {
        line-height: normal!important;
        text-align: right;
        .labelName {
            text-align: right;
        }
    }
</style>